from sqlalchemy.types import TypeDecorator, UserDefinedType
from sqlalchemy.dialects.postgresql import ARRAY, FLOAT

class Vector(UserDefinedType):
    def __init__(self, dim):
        self.dim = dim
        
    def get_col_spec(self, **kw):
        return f"vector({self.dim})"
    
    def bind_processor(self, dialect):
        def process(value):
            if value is None:
                return None
            return value
        return process
    
    def result_processor(self, dialect, coltype):
        def process(value):
            if value is None:
                return None
            return value
        return process 